﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Yule8xCommon.Applib;
using Yule8xCommon.Db;
using Yule8xCommon.Typelib;
using Yule8xModel;

namespace Yule8xWechat.Test
{
    public partial class ReferralDetail : System.Web.UI.Page
    {
        protected System.Data.DataTable dtList;
        protected WxUserInfoResult wxUser;
        protected int child_user_count;
        protected void Page_Load(object sender, EventArgs e)
        {
            int user_id = RequestUtil.GetInteger("user_id");
            if (user_id < 1)
            {
                Response.Write("请输入user_id参数");
                Response.End();
            }
            wxUser = UserModels.GetWxUserInfo(user_id);
            if (null == wxUser)
            {
                Response.Write("未登录");
                Response.End();
            }
            string sqlstmt = string.Format("select u.nickname, u.is_agent, u.regist_time, f.recharge_amount_total from t_user u left join t_user_finance_statistics f on u.user_id=f.user_id where u.parent1_uid={0} or u.parent2_uid={0} order by u.user_id desc", wxUser.user_id);
            LogUtil.Instance.WriteInfo("[推广玩家详情] " + sqlstmt);
            dtList = DbFactory.Init(AppInfo.conn_yule8x_agent).ExecuteDataTable(sqlstmt);

            sqlstmt = string.Format("select count(0) from t_user where parent1_uid={0} or parent2_uid={0}", wxUser.user_id);
            child_user_count = DbFactory.Instance.ExecuteCount(sqlstmt);
        }
    }
}